with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Linked_Lists;

package Tipus is

   package Int_Linked_Lists is new Linked_Lists(Integer);
   use Int_Linked_Lists;

   type State is (Susceptible, Infectat);

   type Sender;
   type PTR_Sender is access Sender;
   type Receiver;
   type PTR_Receiver is access Receiver;


   type Node is record
      Id: Integer;
      Nom: Unbounded_String;
      Num_Connexions: Integer;
      Llista_Connexions: Linked_List;
      Estat: State;
      Rec_Rate : Float;
      Inf_Rate: Float;
      Cont_Cardinality : Integer;
      Prob_inf_inicial : Float;
      tasca_sender : PTR_Sender;
      tasca_receiver: PTR_Receiver;
   end record;

   type Array_Nodes is array(Integer range <>) of Node;
   type PTR_Array_Nodes is access Array_Nodes;

   type Integer_Array is array (Positive range<>) of Integer;
   type PTR_Integer_Array is access Integer_Array;


   task type God is
      entry Rebre_Parametres(Vector_Nodes : PTR_Array_Nodes; Trans : Integer; Est : Integer; Num_Reps : Integer);
      entry Enviament_Acabat;
      entry Recepcio_Acabada;
      entry Informar_Estat(Estat_Estacionari: State);
   end God;

   type PTR_God is access God;


   task type Sender is
      entry Rebre_Punter_Deu (Punter_Deu : PTR_God);
      entry Rebre_Num_Repeticions(Num_Reps : Integer);
      entry Rebre_Parametres (Vector_Nodes : PTR_Array_Nodes; Id: Integer; Trans : Integer; Est : Integer);
      entry Inicia_Enviament (Llavor: Integer);
   end Sender;

   task type Receiver is
      entry Rebre_Punter_Deu (Punter_Deu : PTR_God);
      entry Rebre_Num_Repeticions(Num_Reps : Integer);
      entry Rebre_Parametres (Vector_Nodes : PTR_Array_Nodes; Id: Integer; Trans : Integer; Est : Integer);
      entry Rebre_Connexio (Estat_Rebut: State);
      entry Tothom_Ha_Enviat;
   end Receiver;


end Tipus;
